<?php
namespace Admin\Controller;
use Think\Controller;

class MemberController extends Controller
{
    public function __construct()
    {
        parent::__construct();
        if(!logAdmin(session('adminId'))) header('location:'.U('Admin/Index/login'));
    }

    public function index(){
         
     }
     
     //列出会员信息
     public function Member_list(){
         
          $user=D('User')->SelectInfo();
          $this->assign('memberList',$user['list']);
          $this->assign('page',$user['page']);
          $this->display('Member/member_list');
     }
     
     //编辑会员备注标签
     public function Edit_member(){
          if(IS_GET){
          $uid=I('get.');
          if($uid['id']){
              $result=D('User')->getInfo($uid['id']);
              $this->assign('user',$result['note']);
              $this->assign('id',$uid['id']);
              $this->display('Member/Edit_member');
          }
          }
     }
     
    //保存信息 
     public function save_Info(){
      
         if(IS_POST){
         $info=I('post.');
         if(!empty($info)){
             $result=D('User')->saveInfo($info);
             $result=$result?'修改成功':'修改失败';
             $this->ajaxReturn($result);
         }else{
             $this->ajaxReturn('提交信息出错');
         }
         }
     }
     
     public function Delete_member(){
         if(IS_POST){
         $info=I('post.');
         if(!empty($info)){
              $result=D('User')->delete_member($info);
              $result=$result?true:false;
              $this->ajaxReturn($result);
         }else{
             $this->ajaxReturn('提交信息出错');
         }
         }
     }
     
     public function Delete_all(){
         if(IS_POST){
         $info=I('post.');
         if(!empty($info)){
             $result=D('User')->delete_all($info);
             $result=$result?true:false;
             $this->ajaxReturn($result);
         }else{
             $this->ajaxReturn('提交信息出错');
         }
     }
     }
     
     //模糊查询会员信息
     public function query_Info(){
         if(IS_POST){
             $note=I('post.note');
             $result=D('User')->query_Info($note);
             if(!$result){
                 $this->error('未搜索到任何信息');                 
             }
             $this->assign('memberList',$result);
             $this->display('Member/member_list');
         }
     }
     
     /*
      * 今日注册会员量统计
      */
     
     public function tongji(){
         $map['reg_time']=time();
         $date=date('Y-m-d',time());
         $starttime=strtotime($date." 00:00:00");
         $endtime=strtotime($date." 23:59:59");
         $map['reg_time']=array(array('EGT',$starttime),array('ELT',$endtime),'AND');
         $result=D('User')->SelectInfo($map);
         $this->assign('memberList',$result['list']);
         $this->assign('page',$result['page']);
         $this->display('Member/member_list');
     }
    
}